using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IEnumerableAndIEnumerator : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log(1);
        StartCoroutine(Yield());
        StartCoroutine(Yield2());
        //IEnumerator<int> enumerator = TestYield(4).GetEnumerator();
        //while (enumerator.MoveNext())
        //{
        //    Debug.Log(enumerator.Current);
        //}
    }
    void Update()
    {
        Debug.Log("Update");
    }
    void LateUpdate()
    {
        Debug.Log("LateUpdate");
    }
    public void FixedUpdate()
    {
        Debug.Log("FixedUpdate");
    }

    public void OnGUI()
    {
        Debug.Log ("GUI");
    }
    public IEnumerator Yield() { 
        yield return new WaitForEndOfFrame();
        Debug.Log("Yield");
    }
    public IEnumerator Yield2()
    {
        yield return new WaitForSeconds(0.1f);
        Debug.Log("Yield2");
    }
    public static IEnumerable<int> TestYield(int a)
    {
        yield return a + 1;
        if (a % 2 == 0)
        {
            yield break;
        }
        else
        {
            yield return 1;
        }
        yield return 2;
    }
}
